//
//  UIFont+AD.swift
//  ADKit
//
//  Created by Adoma on 2020/10/22.
//

import UIKit

extension UIFont {
    
    static func _regular(_ size: CGFloat) -> UIFont {
        pingfang(with: size, style: .regular)
    }
    
    static func _medium(_ size: CGFloat) -> UIFont {
        pingfang(with: size, style: .medium)
    }
    
    static func _semibold(_ size: CGFloat) -> UIFont {
        pingfang(with: size, style: .semibold)
    }
    
    public enum FontStyle: String {
        case regular = "PingFangSC-Regular"
        case medium = "PingFangSC-Medium"
        case semibold = "PingFangSC-Semibold"
    }

    /// by ADKit
    public static func pingfang(with size: CGFloat, style: FontStyle = .regular) -> UIFont {
        guard let font = UIFont.init(name: style.rawValue, size: size) else {
            return UIFont.systemFont(ofSize: size)
        }
        return font
    }
}
